package com.kqb.controller;

import com.kqb.common.domain.AjaxResult;
import com.kqb.common.domain.ErrorResult;
import com.kqb.common.domain.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.kqb.service.IPublicUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杉果树皮
 * @date 2025/2/26 8:02
 * @description:
 */
@RestController
@Api(tags = "登录")
@RequestMapping("/api")
public class PublicUserController {
    @Autowired
    private IPublicUserService iPublicUserService;

    @PostMapping("/login")
    @ApiOperation("登录")
    public AjaxResult login(@Validated @RequestBody User user, BindingResult bindingResult) {
        ErrorResult.validate(bindingResult);
        return iPublicUserService.login(user);
    }

}
